/****************************************************************************
** @brief context
****************************************************************************/

#include "gun.h"
#include "status.h"
#include "idleStatus.h"

Gun::Gun(int no) : gun_number_(no)
{
    state_ = IdleStatus::instance();
}

Gun::~Gun()
{

}

void Gun::Process()
{
    state_->Process(this);
}

int Gun::state()
{
    return static_cast<int>(state_->state());
}

char *Gun::card_number()
{
    return (char *) & (card_number_);
}

void Gun::set_card_number(char *data, int len)
{
    for (int i = 0; i < static_cast<int>(sizeof(card_number_)); ++i) {
        card_number_[0] = 0;
    }

    for (int i = 0; i < len && i < static_cast<int>(sizeof(card_number_)); ++i) {
        card_number_[i] = data[i];
    }
}

void Gun::ChangeState(Status *s)
{
    state_ = s;
}
